// [[ OnflowGenerator File UUID: 2d6ef4af8976489cb13fb69ff9f9b510  ]]
package com.itdct.onflow.system.message.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.message.qo.SysMessageEditQo
import com.itdct.onflow.system.message.qo.SysMessageSearchQo
import com.itdct.onflow.system.message.service.SysMessageService
import com.itdct.onflow.system.message.vo.SysMessageDetailVo
import com.itdct.onflow.system.message.vo.SysMessageListVo
import com.itdct.onflow.system.message.vo.SysMessageNotReadCountVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-18 17:04:07
 * @version 1.0
 * @description 系统站内信接口控制
 */
@Tag(name = SysMessageController.moduleName)
@RestController
@RequestMapping(value = ["/sysMessage"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysMessageController(
    val sysMessageService: SysMessageService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统站内信"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysMessageEditQo): RespVo<Long> {
        return sysMessageService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysMessageEditQo): RespVo<Unit> {
        return sysMessageService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysMessageEditQo): RespVo<Unit> {
        return sysMessageService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysMessageSearchQo): RespVo<SysMessageDetailVo> {
        return sysMessageService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysMessageSearchQo): RespPageVo<SysMessageListVo> {
        return sysMessageService.page(qo, getContext())
    }

    @Operation(summary = moduleName + "我的列表")
    @PostMapping("/myPage.adw")
    fun myPage(@RequestBody @Validated(Page::class) qo: SysMessageSearchQo): RespPageVo<SysMessageListVo> {
        return sysMessageService.myPage(qo, getContext())
    }

    @Operation(summary = moduleName + "所有已读")
    @PostMapping("/myAllRead.adw")
    fun myAllRead(@RequestBody eo: SysMessageEditQo): RespVo<Unit> {
        return sysMessageService.myAllRead(eo, getContext())
    }

    @Operation(summary = moduleName + "标记单个已读")
    @PostMapping("/markRead.adw")
    fun markRead(@RequestBody eo: SysMessageEditQo): RespVo<Unit> {
        return sysMessageService.markRead(eo, getContext())
    }

    @Operation(summary = moduleName + "未读数量")
    @PostMapping("/notReadCount.adw")
    fun notReadCount(): RespVo<SysMessageNotReadCountVo> {
        return sysMessageService.notReadCount(getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "标题下拉选")
    @PostMapping("/selectTitleList.adw")
    fun selectTitleList(@RequestBody qo: SysMessageSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysMessageService.selectTitleList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}